<?php
class BookMarkController extends AppController {
	var $name = 'BookMark';

	var $uses = array (
		'BookMark',
		'SysParams'
	);

	function index() {
		if(empty($this->rdAuth->id)){
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login/BookMark');
		
		}
		$this->_setBookMarkData();
	}
	function _setBookMarkData() {

		$member_id = $this->rdAuth->id;
		$data = $this->BookMark->getBookMarkList($this->show,$this->page,$member_id);

		//募集状态
		foreach ($data as &$value){
            $value[0]['recruit']='';
			$start_time=$value[0]['public_start'].' '.$value[0]['public_start_hour'].':'.$value[0]['public_start_min'];
			$end_time=$value[0]['public_end'].' '.$value[0]['public_end_hour'].':'.$value[0]['public_end_min'];
			$today=date('Y-m-d h:m',strtotime('now'));
			$public_end_time=$value[0]['public_close_date'];
			if($today>=$start_time && $today<=$end_time && empty($public_end_time)){
				$value[0]['recruit']='募集中';
			}else{
				$value[0]['recruit']='募集終了';
			}
		}
 		$this->set('data', $data);
 		//lfx added 2013-09-12 start
 		$URLTOASIA=$this->Prop->getValue('config.URLTOASIA');
 		$this->set('URLTOASIA',$URLTOASIA);
 		//lfx added 2013-09-12 end
 		
		//分页显示
		$count = $this->BookMark->getBookMartCount($member_id);
		$this->setPaging('ajax','/BookMark/index',$count,$this->show,null,$this->show);
		
		//分页总数显示
		$pagestr=$this->initPageCount($count,'件','件','中',$this->show);
		$this->set('pagestr',$pagestr);
	}
	function addBookMark(){
		$job_id=$_REQUEST['job_id'];
		$member_id=$_REQUEST['member_id'];
		$this->BookMark->doadd($job_id,$member_id);
		echo '検討中フォルダに登録されています';
		exit;
	}
	function delete_info($bookmark_id){
		if(!empty($bookmark_id)){
			$this->BookMark->dodelete($bookmark_id);
		}
		$this->redirect('/BookMark');
	}
}
?>